﻿using UnityEngine;
using System.Collections;

public static class MathLib {

	public static Vector2 AngleToV2(float angle, float lenght)
	{
		Vector2 direction = Vector2.zero;
		direction.x = (float)Mathf.Sin(angle) * lenght;
		direction.y = (float)Mathf.Cos(angle) * -lenght;
		return direction;
	}

    public static float V2ToAngle(Vector2 direction)
    {
        if (direction == Vector2.zero) return 0;
        direction.Normalize();
        return (float)Mathf.Atan2(direction.x, -direction.y);

    }
}
